package com.ai.web.util;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;

public final class DataUtil {

	private static Logger logger = Logger.getLogger(DataUtil.class);
	
	
	public static <T, E> List<E> buildListVO(List<T> list, Class<E> clazzE) {
		
		List<E> results = new ArrayList<E>();
		
		try {
			
			for (T t : list) {
				E e = clazzE.newInstance();
				
				BeanUtils.copyProperties(t, e);
				results.add(e);
				
			}
			
		} catch (InstantiationException e1) {
			logger.error(e1.getMessage(), e1);
		} catch (IllegalAccessException e1) {
			logger.error(e1.getMessage(), e1);
		} catch (SecurityException e1) {
			logger.error(e1.getMessage(), e1);
		} 
		
		return results;
	}
}
